/** 
 * This is the Test Class for the 'sortData' and 'search' functions of the TextBuddyFunctions Class
 * 
 */

import static org.junit.Assert.*;

import java.io.File;
import java.util.Vector;

import org.junit.Test;


public class TextBuddyFunctionsTest {
	
	/*
	 * Test Case for the search(String searchString) function
	 */
	@Test
	public void testSearch() {
	
	Vector<String> Test = new Vector<String>();
	
	//Test Strings for the Test Vector
	String fileName= "TestFileSearch.txt" ;
	String testStringA="1. Captain America";
	String testStringB="3. Captain Planet";
	
	//Test Strings for the Search Function
	String testData1="Captain America";
	String testData2="Thor";
	String testData3="Captain Planet";
	String testData4="Iron Man";
	
	//String to search
	String wordToSearch = "CAPTAIN";
	
	Test.add(testStringA);
	Test.add(testStringB);
	
	TextBuddyFunctions testSearch=new TextBuddyFunctions(fileName);

	testSearch.addData(testData1); 
	testSearch.addData(testData2);
	testSearch.addData(testData3);
	testSearch.addData(testData4);
    
	Vector<String> temp = testSearch.search(wordToSearch);
	
	assertEquals(temp,Test);
	
	//Clear file command so test cases can be run multiple times without changing fileName
	testSearch.clearData();
	}

	/*
	 * Test Case for the sortData() function
	 */

	@Test
	public void sortTest() {

		
	Vector<String> Test = new Vector<String>();
	
	//Test Strings for the Test Vector
	String testStringA = "I love CS2103!";
	String testStringB = "Refactoring is cool!";
	String testStringC = "Version Control is so useful";
	
	//Test Strings for the Sort Function
	String testData1="Refactoring is cool!";
	String testData2="Version Control is so useful";
	String testData3="I love CS2103!";
	
	Test.add(testStringA);
	Test.add(testStringB);
	Test.add(testStringC);
	
	String fileName= "TestFileSort.txt" ;
	
	TextBuddyFunctions testSort = new TextBuddyFunctions(fileName);

	testSort.addData(testData1); 
	testSort.addData(testData2);
	testSort.addData(testData3);
	
	Vector<String> temp = testSort.sortData();
	
	assertEquals(temp,Test);
	
	//Clear file command so test cases can be run multiple times without changing fileName
	testSort.clearData();
	}

}


